Micron Document
<!DOCTYPE html>
<html class="client-nojs vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-page-tools-pinned-disabled vector-feature-toc-pinned-clientpref-0 vector-toc-not-available vector-feature-main-menu-pinned-disabled vector-feature-limited-width-clientpref-1 vector-feature-limited-width-content-enabled vector-feature-custom-font-size-clientpref-1 vector-feature-appearance-pinned-clientpref-0 vector-feature-night-mode-enabled skin-theme-clientpref-os vector-sticky-header-enabled" lang="fr" dir="ltr"><head>
<meta charset="UTF-8">
<title>Set (commande)</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/png" href="./_res_/favicon.png">
<link rel="canonical" href="https://fr.wikipedia.org/wiki/Set_(commande)"> <link href="./_mw_/ext.cite.styles.css" rel="stylesheet" type="text/css">
<link href="./_mw_/ext.wikimediamessages.styles.css" rel="stylesheet" type="text/css">
<link href="./_mw_/skins.vector.icons.css" rel="stylesheet" type="text/css">
<link href="./_mw_/skins.vector.search.codex.styles.css" rel="stylesheet" type="text/css">
<link href="./_mw_/skins.vector.styles.css" rel="stylesheet" type="text/css">
<meta name="ResourceLoaderDynamicStyles" content="">
<link rel="stylesheet" type="text/css" href="./_mw_/site.styles.css">
<link rel="stylesheet" type="text/css" href="./_mw_/noscript.css">
<link rel="stylesheet" type="text/css" href="./_res_/footer.css">
<link rel="stylesheet" type="text/css" href="./_res_/vector-2022.css">
</head>
<body class="skin--responsive skin-vector skin-vector-search-vue mediawiki ltr sitedir-ltr mw-hide-empty-elt ns-0 ns-subject page-Set_commande rootpage-Set_commande skin-vector-2022 action-view">
<div class="mw-page-container">
<div class="mw-page-container-inner">
<div class="mw-content-container">
<main id="content" class="mw-body">
<header class="mw-body-header vector-page-titlebar">
<h1 id="firstHeading" class="firstHeading mw-first-heading">set (commande)</h1>
</header>
<a id="top"></a>
<div id="bodyContent" class="vector-body ve-init-mw-desktopArticleTarget-targetContainer" aria-labelledby="firstHeading" data-mw-ve-target-container="">
<div id="contentSub">
<div id="mw-content-subtitle"></div>
</div>
<div id="mw-content-text" class="mw-body-content mw-content-ltr" lang="fr" dir="ltr"><div class="mw-content-ltr mw-parser-output" lang="fr" dir="ltr">
<p class="mw-empty-elt">
</p>
<div class="infobox_v3 infobox infobox--frwiki noarchive" style="width:260px">
<div class="entete icon informatique" style="color: #000000;"><style data-mw-deduplicate="TemplateStyles:r228712691">
/* start https://fr.wikipedia.org/ */


.mw-parser-output .entete.informatique{background-image:url("./_mw_/Picto.nfo.png")}


/* end https://fr.wikipedia.org/ */
</style>
<div>Set</div>
</div>
<p class="mw-empty-elt">


</p>
<table><caption style="color:#000000;">Informations</caption>


























<tbody><tr>
<th scope="row"><a href="Syst%C3%A8me_d'exploitation" title="Système d'exploitation">Système d'exploitation</a></th>
<td>
<span class="wd_p306"><a href="MS-DOS" title="MS-DOS">MS-DOS</a> et <a href="Microsoft_Windows" title="Microsoft Windows">Microsoft Windows</a></span></td>
</tr>











<tr>
<th scope="row"> Type
</th>
<td>
<span class="wd_p31">Utilitaire UNIX <small>(<a href="https://www.wikidata.org/wiki/Q18343316" class="extiw external" title="d:Q18343316"><span class="indicateur-langue" title="Voir l'élément Wikidata correspondant">d</span></a>)</small><br>Commande MS-DOS <small>(<a href="https://en.wikipedia.org/wiki/MS-DOS_commands" class="extiw external" title="en:MS-DOS commands"><span class="indicateur-langue" title="Article sur Wikipédia en anglais">en</span></a>)</small></span></td>
</tr>









</tbody></table>
<p class="mw-empty-elt">

</p>
</div>
<p><b>Set</b> est une <a href="Commande_informatique" title="Commande informatique">commande</a> sous <a href="Microsoft_Windows" title="Microsoft Windows">Windows</a> et sous <a href="Unix" title="Unix">Unix</a> (y compris <a href="Linux" title="Linux">Linux</a>) qui affiche les <a href="Variable_d'environnement" title="Variable d'environnement">variables d’environnement</a>.
</p>

<div class="mw-heading mw-heading2"><h2 id="Commande_set_sur_Windows">Commande <i>set</i> sur Windows</h2></div>
<p>La commande <i>set</i> sans aucun paramètre permet de lister les variables d’environnement. Les variables liées au <a href="Shell_(informatique)" class="mw-redirect" title="Shell (informatique)">shell</a> ne sont pas affichées (exemple&nbsp;: %ERRORLEVEL%<sup id="cite_ref-1" class="reference"><a href="#cite_note-1"><span class="cite-bracket">[</span>1<span class="cite-bracket">]</span></a></sup>, %DATE%, %TIME%, <a href="Cd_(Unix)" class="mw-redirect" title="Cd (Unix)">%CD%</a>, %RANDOM% etc.)
</p><p>Cette commande permet aussi de paramétrer une variable d'environnement.
</p>
<pre>set VARIABLE=value
</pre>
<p>Exemple de résultat de cette commande sur <a href="Windows_7" title="Windows 7">Windows 7</a> (pour un utilisateur appelé Dupont sur un ordinateur dont le <i>hostname</i> est <i>monbeaupc</i>:
</p>
<pre>ALLUSERSPROFILE=C:\ProgramData
APPDATA=C:\Users\dupont\AppData\Roaming
CommonProgramFiles=C:\Program Files\Common Files
CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
CommonProgramW6432=C:\Program Files\Common Files
<a href="Variable_d'environnement#%COMPUTERNAME%" title="Variable d'environnement">COMPUTERNAME</a>=monbeaupc
<a href="Cmd.exe" class="mw-redirect" title="Cmd.exe">ComSpec=C:\Windows\system32\cmd.exe</a>
FP_NO_HOST_CHECK=NO
<a href="Variable_d'environnement#%HOMEDRIVE%" title="Variable d'environnement">HOMEDRIVE=C</a>:
<a href="Variable_d'environnement#%HOMEPATH%" title="Variable d'environnement">HOMEPATH</a>=\Users\dupont
LOCALAPPDATA=C:\Users\dupont\AppData\Local
LOGONSERVER=\\MONBEAUPC
<a href="Multiprocesseur" title="Multiprocesseur">NUMBER_OF_PROCESSORS=8</a>
<a href="Syst%C3%A8me_d'exploitation" title="Système d'exploitation">OS</a>=<a href="Windows_NT" title="Windows NT">Windows NT</a>
<a href="Variable_d'environnement#Sous_Windows_:_%PATH%" title="Variable d'environnement">Path</a>=C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\Windows\system32;C:\Windows;<a href="Windows_Management_Instrumentation" title="Windows Management Instrumentation">C:\Windows\System32\Wbem</a>;C:\Windows\System32\Windows<a href="PowerShell" class="mw-redirect" title="PowerShell">PowerShell</a>\v1.0\;C:\Program Files (x86)\Windows Live\Shared
<a href="Session_Manager_Subsystem#Variables_d'environnement" title="Session Manager Subsystem">PATHEXT</a>=<a href=".com_(MS-DOS)" title=".com (MS-DOS)">.COM</a>;<a href="Fichier_ex%C3%A9cutable" title="Fichier exécutable">.EXE</a>;<a href=".BAT" class="mw-redirect" title=".BAT">.BAT</a>;<a href="Cmd.exe" class="mw-redirect" title="Cmd.exe">.CMD</a>;<a href="VBScript" title="VBScript">.VBS</a>;<a href="Visual_Basic_for_Applications" title="Visual Basic for Applications">.VBE</a>;<a href="JScript" title="JScript">.JS</a>;.JSE;<a href="Windows_Scripting_Host" title="Windows Scripting Host">.WSF;.WSH</a>;<a href="Microsoft_Management_Console" title="Microsoft Management Console">.MSC</a>
<a href="X86" title="X86">PROCESSOR_ARCHITECTURE</a>=<a href="AMD64" title="AMD64">AMD64</a>
PROCESSOR_IDENTIFIER=<a href="Intel" title="Intel">Intel</a>64 Family 6 Model 30 Stepping 5, <a href="Genuine" class="mw-disambig" title="Genuine">Genuine</a>Intel
PROCESSOR_LEVEL=6
PROCESSOR_REVISION=1e05
ProgramData=C:\ProgramData
<a href="Program_Files" title="Program Files">ProgramFiles=C:\Program Files</a>
ProgramFiles(x86)=C:\Program Files (x86)
ProgramW6432=C:\Program Files
<a href="Variable_d'environnement#%PROMPT%" title="Variable d'environnement">PROMPT</a>=$P$G
PSModulePath=C:\Windows\system32\Windows<a href="PowerShell" class="mw-redirect" title="PowerShell">PowerShell</a>\v1.0\Modules\
PUBLIC=C:\Users\Public
SESSIONNAME=Console
SystemDrive=C:
SystemRoot=C:\Windows
TEMP=C:\Users\dupont\AppData\Local\Temp
TMP=C:\Users\dupont\AppData\Local\Temp
USERDOMAIN=monbeaupc
USERNAME=dupont
USERPROFILE=C:\Users\dupont
windir=C:\Windows
</pre>
<div class="mw-heading mw-heading2"><h2 id="Commande_set_sur_Unix">Commande <i>set</i> sur Unix</h2></div>
<p>La commande <i>set</i> sans aucun paramètre liste à la fois les <a href="Variable_d'environnement" title="Variable d'environnement">variables d'environnement</a> et les <a href="Variable_d'environnement#Les_variables_autres_que_celles_d'environnement" title="Variable d'environnement">variables liées au shell</a>. Cette commande est spécifique du <a href="Shell_Unix" title="Shell Unix">Shell Unix</a> utilisée (<a href="Bourne-Again_shell" title="Bourne-Again shell">bash</a>, <a href="Korn_shell" title="Korn shell">ksh</a>, <a href="Bourne_shell" title="Bourne shell">sh</a>, etc.). Toutefois des paramètres sont disponibles<sup id="cite_ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">[</span>2<span class="cite-bracket">]</span></a></sup>.
</p><p>La commande <i><a href="Unset_(Unix)" class="mw-redirect" title="Unset (Unix)">unset</a></i> permet de détruire une variable d'environnement.
</p>
<div class="mw-heading mw-heading3"><h3 id="Commande_&quot;shopt&quot;_sur_les_versions_récentes_de_bash"><span id="Commande_.22shopt.22_sur_les_versions_r.C3.A9centes_de_bash"></span>Commande "shopt" sur les versions récentes de bash</h3></div>
<p>Depuis la version 2.0 du bash, il existe une commande supplémentaire à <i>set</i>&nbsp;: c'est la commande <i>shopt</i>&nbsp;; elle a un comportement très semblable à <i>set</i>.
</p>
<div class="mw-heading mw-heading2"><h2 id="Notes_et_références"><span id="Notes_et_r.C3.A9f.C3.A9rences"></span>Notes et références</h2></div>
<div class="references-small decimal" style=""><div class="mw-references-wrap"><ol class="references">
<li id="cite_note-1"><span class="mw-cite-backlink"><a href="#cite_ref-1">↑</a> </span><span class="reference-text">Voir le document <span class=" plainlinksneverexpand noarchive"><span class="lang-fr" lang="fr"><a class="external text" href="https://fr.wikibooks.org/wiki/fr:Cmd.exe#ERRORLEVEL">cmd.exe, section «&nbsp;ERRORLEVEL&nbsp;»</a></span> sur Wikibooks</span>.</span>
</li>
<li id="cite_note-2"><span class="mw-cite-backlink"><a href="#cite_ref-2">↑</a> </span><span class="reference-text"><span class="ouvrage"><abbr class="abbr indicateur-langue" title="Langue : anglais">(en)</abbr> «&nbsp;<a rel="nofollow" class="external text" href="http://linuxcommand.org/lc3_man_pages/seth.html"><cite style="font-style:normal;" lang="en">Set man page</cite></a>&nbsp;», sur <span class="italique">linuxcommand.org</span> <small style="line-height:1em;">(consulté le <time class="nowrap" datetime="2023-10-01" data-sort-value="2023-10-01"><abbr class="abbr" title="premier">1<sup>er</sup></abbr> octobre 2023</time>)</small></span>.</span>
</li>
</ol></div>
</div>
<div class="mw-heading mw-heading2"><h2 id="Voir_aussi">Voir aussi</h2></div>
<style data-mw-deduplicate="TemplateStyles:r194021218">
/* start https://fr.wikipedia.org/ */


.mw-parser-output .autres-projets>.titre{text-align:center;margin:0.2em 0}.mw-parser-output .autres-projets>ul{margin:0;padding:0}.mw-parser-output .autres-projets>ul>li{list-style:none;margin:0.2em 0;text-indent:0;padding-left:24px;min-height:20px;text-align:left;display:block}.mw-parser-output .autres-projets>ul>li>a{font-style:italic}@media(max-width:720px){.mw-parser-output .autres-projets{float:none}}


/* end https://fr.wikipedia.org/ */
</style>
<div class="navbox-container" style="clear:both;">


</div>
<ul id="bandeau-portail" class="bandeau-portail"><li><span class="bandeau-portail-element"><span class="bandeau-portail-icone"><span class="noviewer" typeof="mw:File"></span></span> <span class="bandeau-portail-texte">Portail de l’informatique</span> </span></li> </ul></div><!--htdig_noindex--><div><div class="zim-footer">
Cet article est issu de <a class="external text" title="Dernière modification le 2024-06-21" href="https://fr.wikipedia.org/wiki/?title=Set_(commande)&amp;oldid=216116243">Wikipédia</a>. Sauf mention contraire, le texte est disponible sous <a class="external text" href="https://creativecommons.org/licenses/by-sa/4.0/deed.fr">Creative Commons Attribution-Share Alike 4.0</a>. Des conditions supplémentaires peuvent s’appliquer aux fichiers multimédias.
</div>
</div><!--/htdig_noindex--></div>
</div>
</main>
</div>
</div>
</div>
<script src="./_webp_/webpHandler.js"></script>

</body></html>